﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section script{
<script type="text/javascript" src="/scripts/jquery-1.4.4.min.js"></script> 
<script type="text/javascript" src="/scripts/swfupload/swfupload.js"></script>
<script type="text/javascript" src="/scripts/swfupload/jquery.swfupload.js"></script>
<script type="text/javascript">
    $(function () {
        $('#swfupload-control').swfupload({
            upload_url: "/home/SWFPrepareUpload",
            file_size_limit: "7 MB",
            file_types: "*.jpg;*.png",
            file_types_description: "Web Image Files",
            file_upload_limit: 0,
            flash_url: "/scripts/swfupload/swfupload.swf",
            button_image_url: '/scripts/swfupload/btn_upload.png',
            button_width: 125,
            button_height: 40,
            button_placeholder: $('#button')[0]
        })
        .bind('swfuploadLoaded', function (event) {
            //$('#log').append('<li>Loaded</li>');
        })
        .bind('fileQueued', function (event, file) {
            //$('#log').append('<li>File queued - ' + file.name + '</li>');
            //start the upload since it's queued
            $(this).swfupload('startUpload');
        })
        .bind('fileQueueError', function (event, file, errorCode, message) {
            alert('12');
            //$('#log').append('<li>File queue error - ' + message + '</li>');
        })
        .bind('fileDialogStart', function (event) {
            //$('#log').append('<li>File dialog start</li>');
        })
        .bind('fileDialogComplete', function (event, numFilesSelected, numFilesQueued) {
            //$('#log').append('<li>File dialog complete</li>');
        })
        .bind('uploadStart', function (event, file) {
            //$('#log').append('<li>Upload start - ' + file.name + '</li>');
        })
        .bind('uploadProgress', function (event, file, bytesLoaded) {
            //$('#log').append('<li>Upload progress - ' + bytesLoaded + '</li>');
        })
        .bind('uploadSuccess', function (event, file, serverData) {
            //$('#log').append('<li>Upload success - ' + file.name + '</li>');
            //$('#imgbox').append($('<img src="' + serverData + '" />'));
        })
        .bind('uploadComplete', function (event, file) {
            //$('#log').append('<li>Upload complete - ' + file.name + '</li>');
            // upload has completed, lets try the next one in the queue
            $(this).swfupload('startUpload');
        })
        .bind('uploadError', function (event, file, errorCode, message) {
            //$('#log').append('<li>Upload error - ' + message + '</li>');
        });

    });
</script>
}
<div id="swfupload-control">
<div>
   @* <ol id="log"></ol>*@
    <input type="button" id="button" />
</div>
</div>